Conditions | 9 |
Paths | 288 |
Total Lines | 54 |
Code Lines | 38 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | // Buttons |
||
34 | init: function(notice, options){ |
||
35 | var that = this; |
||
36 | this.myOptions = options; |
||
37 | notice.elem.on({ |
||
38 | "mouseenter": function(e){ |
||
|
|||
39 | // Show the buttons. |
||
40 | if (that.myOptions.sticker && !(notice.options.nonblock && notice.options.nonblock.nonblock)) that.sticker.trigger("pnotify_icon").css("visibility", "visible"); |
||
41 | if (that.myOptions.closer && !(notice.options.nonblock && notice.options.nonblock.nonblock)) that.closer.css("visibility", "visible"); |
||
42 | }, |
||
43 | "mouseleave": function(e){ |
||
44 | // Hide the buttons. |
||
45 | if (that.myOptions.sticker_hover) |
||
46 | that.sticker.css("visibility", "hidden"); |
||
47 | if (that.myOptions.closer_hover) |
||
48 | that.closer.css("visibility", "hidden"); |
||
49 | } |
||
50 | }); |
||
51 | |||
52 | // Provide a button to stick the notice. |
||
53 | this.sticker = $("<div />", { |
||
54 | "class": "ui-pnotify-sticker", |
||
55 | "css": {"cursor": "pointer", "visibility": options.sticker_hover ? "hidden" : "visible"}, |
||
56 | "click": function(){ |
||
57 | notice.options.hide = !notice.options.hide; |
||
58 | if (notice.options.hide) |
||
59 | notice.queueRemove(); |
||
60 | else |
||
61 | notice.cancelRemove(); |
||
62 | $(this).trigger("pnotify_icon"); |
||
63 | } |
||
64 | }) |
||
65 | .bind("pnotify_icon", function(){ |
||
66 | $(this).children().removeClass(notice.styles.pin_up+" "+notice.styles.pin_down).addClass(notice.options.hide ? notice.styles.pin_up : notice.styles.pin_down); |
||
67 | }) |
||
68 | .append($("<span />", {"class": notice.styles.pin_up, "title": options.labels.stick})) |
||
69 | .prependTo(notice.container); |
||
70 | if (!options.sticker || (notice.options.nonblock && notice.options.nonblock.nonblock)) |
||
71 | this.sticker.css("display", "none"); |
||
72 | |||
73 | // Provide a button to close the notice. |
||
74 | this.closer = $("<div />", { |
||
75 | "class": "ui-pnotify-closer", |
||
76 | "css": {"cursor": "pointer", "visibility": options.closer_hover ? "hidden" : "visible"}, |
||
77 | "click": function(){ |
||
78 | notice.remove(false); |
||
79 | that.sticker.css("visibility", "hidden"); |
||
80 | that.closer.css("visibility", "hidden"); |
||
81 | } |
||
82 | }) |
||
83 | .append($("<span />", {"class": notice.styles.closer, "title": options.labels.close})) |
||
84 | .prependTo(notice.container); |
||
85 | if (!options.closer || (notice.options.nonblock && notice.options.nonblock.nonblock)) |
||
86 | this.closer.css("display", "none"); |
||
87 | }, |
||
88 | update: function(notice, options){ |
||
133 |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.